﻿using System;

namespace TinyContainer
{
    /// <summary>
    /// The primary interface to the <c>TinyContainer</c> IoC container.
    /// </summary>
    public interface IContainer
    {
        /// <summary>
        /// Resolves an object that implements the specified type.
        /// </summary>
        /// <typeparam name="T">The type to resolve.</typeparam>
        /// <param name="name">The name of the object.</param>
        /// <returns>An object that implements the specified type.</returns>
        T Resolve<T>(string name="");

        /// <summary>
        /// Resolves the specified object.
        /// </summary>
        /// <param name="type">The type of the object.</param>
        /// <param name="name">The name of the object.</param>
        /// <returns>An object of the specified type.</returns>
        object Resolve(Type type,string name="");
       
        /// <summary>
        /// Overloaded. Registers an object instance under an alias.
        /// </summary>
        /// <typeparam name="T">The type of the object.</typeparam>
        /// <typeparam name="TC">The name of the object.</typeparam>
        /// <param name="name">The alias of the object.</param>
        void Register<T,TC>(string name="") where TC:T;


        /// <summary>
        /// Overloaded. Registers an object instance.
        /// </summary>
        /// <typeparam name="T">The type of the object.</typeparam>
        /// <param name="instance">The type of the object instance.</param>
        /// <param name="name">The name of the object.</param>
        void Register<T>(T instance,string name="");


        /// <summary>
        /// Checks whether the specified object is registered.
        /// </summary>
        /// <typeparam name="T">The type of the object.</typeparam>
        /// <param name="name">The name of the object.</param>
        /// <returns>
        ///   <c>True</c> if the specified name is registered; otherwise, <c>False</c>.
        /// </returns>
        bool IsRegistered<T>(string name="");


        /// <summary>
        /// Deletes the specified object instance from the container registry.
        /// </summary>
        /// <param name="instance">The name of the object instance.</param>
        void Remove(object instance);
    }
}
